package com.hnkywl.sts.entity.djgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.cggl.Cgd;
import com.hnkywl.sts.entity.cggl.Jsd;
import com.hnkywl.sts.entity.jhgl.Bgjhhzmx;
import com.hnkywl.sts.entity.sys.Gg;
import com.hnkywl.sts.entity.xsgl.Kh;
import org.hibernate.annotations.*;

import javax.persistence.Entity;
import javax.persistence.*;
import javax.persistence.Table;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZHUCHG
 * Date: 13-4-15
 * Time: 下午3:19
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "T_BIZ_CGDMX")
@Where(clause = "deleted ='1'")
public class Cgdmxx extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqCgdmx", allocationSize = 1, sequenceName = "SEQ_BIZ_CGDMX")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqCgdmx")
    private Long id;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGD_ID")
    private Cgd cgd;
    // 物资
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GG_ID")
    private Gg gg;
    // 图号
    private String th;
    // 产地
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SJZDZ_CD_ID")
    private Sjzdz cd;
    // 长/宽
    private String ck;
    // 计重方式
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SZJDZ_JZFS_ID")
    private Sjzdz jzfs;
    // 关联卡号
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "KH_ID")
    private Kh kh;
    // 件数
    private Integer js;
    // 数量
    private Double sbsl;
    // 含税价
    private Double hsj;
    // 不含税价
    private Double bhsj;
    //入库件数
    private Integer rkjs;
    //入库数量
    private Double rksl;
    //实时件数
    private Integer ssjs;
    //实时数量
    private Double sssl;

    //入库件重
    private Double rkjz;
    //入库_含税价
    private Double rkhsj;
    //入库_不含税价
    private Double rkbhsj;

    /**
     * 牌号
     */
    private String ph;

    //结算_含税价
    private Double jshsj;
    //结算_不含税价
    private Double jsbhsj;

    //结算_不含税额
    private Double jsbhse;
    //结算_税额
    private Double jsse;
    //结算_差额
    private Double jsce;
    // 备注
    private String bz;

    //结算单
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGJS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Jsd cgjsd;

    /**
     * 已结算
     */
    private Boolean yjs = false;

    @Formula(" (select hsj * sbsl from T_BIZ_CGDMX t where t.id=ID) ")
    private Double hse;

    @Formula(" (select bhsj * sbsl from T_BIZ_CGDMX t where t.id=ID) ")
    private Double bhse;

    @ManyToMany
    @JoinTable(name = "T_BIZ_JHCGDDZ", joinColumns = {@JoinColumn(name = "CGDMXID")}, inverseJoinColumns = {@JoinColumn(name = "HZMXID")})
    @Where(clause = "deleted!='1'")
    private List<Bgjhhzmx> bgjhhzmxList;

    @Formula(" (select D.zt from t_biz_dhd D where D.cgdmx_id = ID) ")
    private String dhdStr;

    /**
     * 明细行序号
     */
    private Long mxh;


    @OneToMany(fetch = FetchType.LAZY, targetEntity = Kh.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "CGDMX_ID")
    @Where(clause = "deleted!='1'")
    private List<Kh> khList;

    //标示符
    private String sku;

    public List<Kh> getKhList() {
        return khList;
    }

    public void setKhList(List<Kh> khList) {
        this.khList = khList;
    }

    public String getSku() {
        return sku;
    }

    public void setSku(String sku) {
        this.sku = sku;
    }

    public String getDhdStr() {
        return dhdStr;
    }

    public void setDhdStr(String dhdStr) {
        this.dhdStr = dhdStr;
    }

    public Double getHse() {
        return hse;
    }

    public void setHse(Double hse) {
        this.hse = hse;
    }

    public Double getBhse() {
        return bhse;
    }

    public void setBhse(Double bhse) {
        this.bhse = bhse;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Cgd getCgd() {
        return cgd;
    }

    public void setCgd(Cgd cgd) {
        this.cgd = cgd;
    }

    public Gg getGg() {
        return gg;
    }

    public void setGg(Gg gg) {
        this.gg = gg;
    }

    public String getTh() {
        return th;
    }

    public void setTh(String th) {
        this.th = th;
    }

    public Sjzdz getCd() {
        return cd;
    }

    public void setCd(Sjzdz cd) {
        this.cd = cd;
    }

    public String getCk() {
        return ck;
    }

    public void setCk(String ck) {
        this.ck = ck;
    }

    public Sjzdz getJzfs() {
        return jzfs;
    }

    public void setJzfs(Sjzdz jzfs) {
        this.jzfs = jzfs;
    }

    public Kh getKh() {
        return kh;
    }

    public void setKh(Kh kh) {
        this.kh = kh;
    }

    public Integer getJs() {
        return js;
    }

    public void setJs(Integer js) {
        this.js = js;
    }

    public Double getSbsl() {
        return sbsl;
    }

    public void setSbsl(Double sbsl) {
        this.sbsl = sbsl;
    }

    public Double getHsj() {
        return hsj;
    }

    public void setHsj(Double hsj) {
        this.hsj = hsj;
    }

    public Double getBhsj() {
        return bhsj;
    }

    public void setBhsj(Double bhsj) {
        this.bhsj = bhsj;
    }

    public Integer getRkjs() {
        return rkjs;
    }

    public void setRkjs(Integer rkjs) {
        this.rkjs = rkjs;
    }

    public Double getRksl() {
        return rksl;
    }

    public void setRksl(Double rksl) {
        this.rksl = rksl;
    }

    public String getPh() {
        return ph;
    }

    public void setPh(String ph) {
        this.ph = ph;
    }

    public Double getRkjz() {
        return rkjz;
    }

    public void setRkjz(Double rkjz) {
        this.rkjz = rkjz;
    }

    public Double getRkhsj() {
        return rkhsj;
    }

    public void setRkhsj(Double rkhsj) {
        this.rkhsj = rkhsj;
    }

    public Double getRkbhsj() {
        return rkbhsj;
    }

    public void setRkbhsj(Double rkbhsj) {
        this.rkbhsj = rkbhsj;
    }

    public Double getJshsj() {
        return jshsj;
    }

    public void setJshsj(Double jshsj) {
        this.jshsj = jshsj;
    }

    public Double getJsbhsj() {
        return jsbhsj;
    }

    public void setJsbhsj(Double jsbhsj) {
        this.jsbhsj = jsbhsj;
    }

    public Double getJsbhse() {
        return jsbhse;
    }

    public void setJsbhse(Double jsbhse) {
        this.jsbhse = jsbhse;
    }

    public Double getJsse() {
        return jsse;
    }

    public void setJsse(Double jsse) {
        this.jsse = jsse;
    }

    public Double getJsce() {
        return jsce;
    }

    public void setJsce(Double jsce) {
        this.jsce = jsce;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Jsd getCgjsd() {
        return cgjsd;
    }

    public void setCgjsd(Jsd cgjsd) {
        this.cgjsd = cgjsd;
    }

    public Boolean getYjs() {
        return yjs;
    }

    public void setYjs(Boolean yjs) {
        this.yjs = yjs;
    }

    public List<Bgjhhzmx> getBgjhhzmxList() {
        return bgjhhzmxList;
    }

    public void setBgjhhzmxList(List<Bgjhhzmx> bgjhhzmxList) {
        this.bgjhhzmxList = bgjhhzmxList;
    }

    public Long getMxh() {
        return mxh;
    }

    public void setMxh(Long mxh) {
        this.mxh = mxh;
    }

    public Integer getSsjs() {
        return ssjs;
    }

    public void setSsjs(Integer ssjs) {
        this.ssjs = ssjs;
    }

    public Double getSssl() {
        return sssl;
    }

    public void setSssl(Double sssl) {
        this.sssl = sssl;
    }
}
